import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class ThreeMC
{
    public static void main(String[] args)
    {
        int imagesize = 1001;
        int size = imagesize - 1;
        int center = size / 2;
        float increment = (float)size / (float)16;
        int maxCircleReduction = (size / 2) - (int)(increment*2);
        BufferedImage image = 
            new BufferedImage(imagesize, imagesize, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = image.createGraphics();
        Ellipse2D.Double circle =
            new Ellipse2D.Double(0, 0, size, size);
        g2.fill(circle);
        boolean black = true;
        float i = 0;
        while (i < maxCircleReduction)
        {
            if (black)
            {
                g2.setColor(Color.WHITE);
                black = false;
            }
            else
            {
                g2.setColor(Color.BLACK);
                black = true;
            }
            
            //(x - h)2 + (y - k)2 = r2
            
            for (int j = 0; j < 360; j = j + (360 / 24))
            {
                if (black)
                {
                    g2.setColor(Color.WHITE);
                    black = false;
                }
                else
                {
                    g2.setColor(Color.BLACK);
                    black = true;
                }
                
                Polygon p = new Polygon();
                for (double k = 0; k <= 15; k+=0.5)
                {
                    double angle = ((double)j+(double)k)/(double)360;
                    int x = (int)(center + ((center-i) * Math.cos(angle * (2*Math.PI))));
                    int y = (int)(center + ((center-i) * Math.sin(angle * (2*Math.PI))));
                    p.addPoint(x, y);                    
                }
                for (double k = 15; k >= 0; k-=0.5)
                {
                    double angle = ((double)j+(double)k)/(double)360;
                    int x = (int)(center + ((center-(i + increment)) * Math.cos(angle * (2*Math.PI))));
                    int y = (int)(center + ((center-(i + increment)) * Math.sin(angle * (2*Math.PI))));
                    p.addPoint(x, y);                    
                }
                g2.fillPolygon(p);
                //g2.drawArc((int)i, (int)i, (int)(999 - (2*i)), (int)(999 - (2*i)), j, (360 / 24));
                //g2.drawArc((int)(i + 625), (int)(i + 625), (int)(999 - (2*(i + 625))), (int)(999 - (2*(i + 625))), j, (360 / 24));
                
            }
            g2.setColor(Color.BLACK);
            
            i+= increment;
            circle = new Ellipse2D.Double(i, i, size - (2*i), size - (2*i));
            g2.draw(circle);
            
        }
        g2.setColor(Color.BLACK);
        circle = new Ellipse2D.Double(0, 0, size, size);
        g2.draw(circle);
        
        g2.setColor(Color.WHITE);
        circle = new Ellipse2D.Double(maxCircleReduction+1, maxCircleReduction+1, size - (2*(maxCircleReduction+1)), size - (2*maxCircleReduction+1));
        g2.fill(circle);
        
        try {
            BufferedImage bi = image; // retrieve image
            File outputfile = new File("saved.png");
            ImageIO.write(bi, "png", outputfile);
        } catch (IOException e) {

        }
        
    }
}
